package com.woniu.micropropertyserver.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;

import com.github.pagehelper.util.PageObjectUtil;
import com.woniu.microcommonsserver.entity.PropertyIcCheck;
import com.woniu.micropropertyserver.mapper.PropertyIcMapper;
import com.woniu.micropropertyserver.service.IPropertyIcCheckService;
import com.woniu.micropropertyserver.util.PageRest;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Isolation;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import java.util.Date;
import java.util.HashMap;
import java.util.List;

/**
 * @author ：bb
 * @date ：Created in 2021/1/29 0029
 * @description：
 * @modified By：
 * @version: $
 */
@Service
public class PropertyIcCheckServiceImpl  implements IPropertyIcCheckService {

    @Resource
    private PropertyIcMapper propertyIcMapper;

    @Override
    public List<HashMap> findAll() {
        return null;
    }



    @Override
    public PageInfo<PropertyIcCheck> findByParams(PageRest pageRest, PropertyIcCheck propertyIcCheck)
    {
        System.out.println(propertyIcMapper.findByParams(pageRest,propertyIcCheck));
        return PageHelper.startPage(pageRest.getPageNum(),pageRest.getPageSize()).doSelectPageInfo(()->propertyIcMapper.findByParams(pageRest,propertyIcCheck));
    }

    @Override
    @Transactional(isolation = Isolation.DEFAULT,rollbackFor = Exception.class)
    public int delInfo(Long[] ids) {
        return propertyIcMapper.delInfo(ids);
    }

    @Override
    @Transactional(isolation = Isolation.DEFAULT,rollbackFor = Exception.class)
    public int updateDate(Long[] ids, Date authorizeStartDate, Date authorizeEndDate) {
        Date now = new Date();
        return propertyIcMapper.updateDate(ids,authorizeStartDate,authorizeEndDate,now);
    }


    @Override
    @Transactional(isolation = Isolation.DEFAULT,rollbackFor = Exception.class)
    public int updateAuth(PropertyIcCheck propertyIcCheck) {
        return propertyIcMapper.updateAuth(propertyIcCheck);
    }

    @Override
    @Transactional(isolation = Isolation.DEFAULT,rollbackFor = Exception.class)
    public int saveAuth(PropertyIcCheck propertyIcCheck) {
        return propertyIcMapper.saveAuth(propertyIcCheck);
    }

    @Override
    public PropertyIcCheck findById(Long id) {
        return propertyIcMapper.findById(id);
    }

    @Override
    public int saveInfo(PropertyIcCheck p) {
        return propertyIcMapper.saveAuth(p);
    }
}
